package com.ruoyi.web.controller.tag;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tag.domain.PostTagsRel;
import com.ruoyi.tag.service.IPostTagsRelService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 帖子与标签中间表Controller
 * 
 * @author ruoyi
 * @date 2025-06-17
 */
@RestController
@RequestMapping("/ptr/ptr")
@Tag(name = "【帖子与标签中间表】管理")
public class PostTagsRelController extends BaseController
{
    @Autowired
    private IPostTagsRelService postTagsRelService;

    /**
     * 新增帖子与标签中间表
     */
    @Operation(summary = "新增帖子与标签中间表")
    @Log(title = "帖子与标签中间表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody List<PostTagsRel> postTagsRelList)
    {
        return toAjax(postTagsRelService.insertPostTagsRel(postTagsRelList));
    }

    /**
     * 评论删除帖子与标签中间表
     */
    @Operation(summary = "评论删除帖子与标签中间表")
    @Log(title = "帖子与标签中间表", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete")
    public AjaxResult remove(@RequestBody List<PostTagsRel> postTagsRelList)
    {
        return toAjax(postTagsRelService.deletePostTagsRelByList(postTagsRelList));
    }
}
